/******************************************************************************\
*                                                                              *
*     File: Dierentuin_test.cpp                                                *
*                                                                              *
*   Author: Douwe A. van Twillert                                              *
*  Purpose: test van de klasse Dierentuin                                      *
*  Version: 1.0      TWI 20080218                                              *
*           - Initial version                                                  *
*                                                                              *
\******************************************************************************/

#include <string>

#include "TestSet.h"

#include "FileSystem.h"

char* path = "/home/floppie";

TEST_SET( FileSystemTests );



TEST(FileSystemTest)
	FileSystem* fs = new FileSystem(path);
	CHECK(fs!=0);
	delete fs;
END_TEST

TEST(FindInodeByNumberRoot)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInodeByNumber(2);
	CHECK(inode != 0);
	CHECK(inode->getMode() == 040777);
	CHECK(inode->getFileSize() == 816);
	delete inode;
	delete fs;
END_TEST

TEST(FindInodeByPathRoot)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInode("/");
	CHECK(inode != 0);
	CHECK(inode->getMode() == 040777);
	CHECK(inode->getFileSize() == 816);
	delete inode;
	delete fs;
END_TEST

TEST(FindInodeByPathRoot2)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInode("/.");
	CHECK(inode != 0);
//	CHECK(inode->getMode() == 040777);
//	CHECK(inode->getFileSize() == 816);
	delete inode;
	delete fs;
END_TEST

TEST(FindInodeByPathMega)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInode("/mega");
	CHECK(inode != 0);
//	cout << inode->getMode();
//	CHECK(inode->getMode() == 100644);
//	CHECK(inode->getFileSize() == 1026086);
	delete inode;
	delete fs;
END_TEST

TEST(FindInodeByNumberMega)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInodeByNumber(4);
	CHECK(inode != 0);
	CHECK(inode->getMode() == 100644);
	CHECK(inode->getFileSize() == 1026086);
	delete inode;
	delete fs;
END_TEST

TEST(InodeMode)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInodeByNumber(4);
	CHECK(inode != 0);
	CHECK(inode->getMode() == 100644);
	delete inode;
	delete fs;
END_TEST

TEST(InodeFilesite)
	FileSystem *fs = new FileSystem(path);

	Inode* inode = fs->findInodeByNumber(4);
	CHECK(inode != 0);
	CHECK(inode->getFileSize() == 1026086);
	delete inode;
	delete fs;
END_TEST

TEST(GetBlock)
	FileSystem *fs = new FileSystem(path);

	Blok* block = fs->getBlok(213);
	CHECK(block!=0);
	CHECK(block->getUsecount()>0);
	delete fs;
END_TEST


int main()
{
    return TestSet_execute();
}
